import { todoType, todoListType } from "../types/todo";
import {ref} from 'vue'
export function useLocalStorage(key: string, val?: todoListType) {
    let data;
    if (val) {
        localStorage.setItem(key, JSON.stringify(val))
    } else {
        // 变量后使用 !:——表示类型推断排除null、undefined
        data = JSON.parse(localStorage.getItem(key)!)

    }
    return data
}

  